﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Function.Master" AutoEventWireup="true" CodeBehind="ProductList.aspx.cs" Inherits="LEARNREN.COM.WebSite.Admin.ProductList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
 <script type="text/javascript">
     var dataTableInPage;

     $(document).ready(function () {
         dataTableInPage = showDataTable();
     });
     function showDataTable() {
         var dt = dataTableExt("ProductListHandler.ashx", "dataTable",
                        [{ "sClass": "center", "mDataProp": "Id", "width": 60 },
                        { "sClass": "center", "mDataProp": "ProductName" },
                        { "sClass": "center", "mDataProp": "CreatedTime", "width": 130 },
                        {
                            //自定义列
                            "mDataProp": "Id",
                            "width": 120,
                            "sClass": "center",
                            "bSearchable": false,
                            "bStorable": false,
                            "bStateSave": true,
                            "mRender": function (obj, display, fullData) {
                                return '<a href="#" class="inlineButton" onclick=\"showEditpannel(' + obj + ',\'' + fullData.ProductName + '\');return false;\">编辑</a>&nbsp;&nbsp;<a href=\"#\" class="inlineButton" onclick=\"deleteProduct(' + obj + ');return false;\">删除</a>';
                            }
                        }]);
         return dt;
     }

     function showEditpannel(id, title) {
         showTab("tabs-editProduct" + id, title, "ProductEdit.aspx?action=Edit&id=" + id);
         return false;
     }


     function deleteProduct(id) {
         if (confirm("确定要删除此产品吗？")) {
             $.post("ProductHandler.ashx",
                { o: 0, id: id },
                function (data) {
                    if (!data) {
                        showDialog("删除失败！", "提示");
                    }
                    else {
                        if (data.result) {
                            showDialog("删除成功！", "提示");
                            if (dataTableInPage) {
                                dataTableInPage.fnStandingRedraw();
                            }
                        }
                        else {
                            showDialog("删除失败！", "提示");
                        }
                    }
                },
                "json");
         }
         return false;
     }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
   <table id="dataTable" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>ID</th>
                <th>产品名称</th>
                <th>发布时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</asp:Content>
